home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / julian1a / julianda.cls
Text File  |  1999-10-12  |  3KB  |  111 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "JulianDate"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
  15. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  16. Option Explicit
  17. Private Month As String
  18. Private Day As String
  19. Private Year As String
  20.  
  21. 'local variable(s) to hold property value(s)
  22. Private mvarJulian As String 'local copy
  23.  
  24. Public Property Get Julian() As String
  25. Attribute Julian.VB_Description = "Julian date output"
  26.     'Assign the output date string to the public .Julian property
  27.     Julian = mvarJulian
  28. End Property
  29.  
  30. 'Creates a Julian date based on current time/date
  31. Public Sub MakeJulianDate()
  32.  
  33.     'Get the date and separate it into its components
  34.     Month = Left$(Format$(Now, "mmddyyyy"), 2)
  35.     Day = Mid$(Format$(Now, "mmddyyyy"), 3, 2)
  36.     Year = Right$(Format$(Now, "mmddyyyy"), 4)
  37.     
  38.     'Determine the base count for figuring Julian date by assigning
  39.     'cumulative day count to month #
  40.     Select Case Val(Month)
  41.         'Jan
  42.         Case 1
  43.             Month = 0
  44.         'Feb
  45.         Case 2
  46.             Month = 31
  47.         'Mar
  48.         Case 3
  49.             Month = 59
  50.         'Apr
  51.         Case 4
  52.             Month = 90
  53.         'May
  54.         Case 5
  55.             Month = 120
  56.         'Jun
  57.         Case 6
  58.             Month = 151
  59.         'Jul
  60.         Case 7
  61.             Month = 181
  62.         'Aug
  63.         Case 8
  64.             Month = 212
  65.         'Sep
  66.         Case 9
  67.             Month = 243
  68.         'Oct
  69.         Case 10
  70.             Month = 273
  71.         'Nov
  72.         Case 11
  73.             Month = 304
  74.         'Dec
  75.         Case 12
  76.             Month = 334
  77.     End Select
  78.     
  79.     'Add the base count and day offset to get the initial Julian date,
  80.     'uncompensated for leap years
  81.     Month = Str$(Val(Month) + Val(Day))
  82.     Select Case Len(Month)
  83.         Case 2
  84.             Month = "00" & Right$(Month, 1)
  85.         Case 3
  86.             Month = "0" & Right$(Month, 2)
  87.     End Select
  88.     
  89.     'Now check for leap years and adjust the Julian date
  90.     'by one to account for Feb 29
  91.     If Val(Year) Mod 4 = 0 And Val(Year) Mod 100 = 0 Then
  92.         If Val(Year) Mod 400 = 0 And Val(Month) > 59 Then
  93.             Month = Str$(Val(Month) + 1)
  94.         End If
  95.     ElseIf Val(Year) Mod 4 = 0 And Val(Month) > 59 Then
  96.         Month = Str$(Val(Month) + 1)
  97.     End If
  98.     
  99.     Select Case Len(Month)
  100.         Case 1
  101.             Month = "00" & Right$(Month, 1)
  102.         Case 2
  103.             Month = "0" & Right$(Month, 2)
  104.     End Select
  105.     
  106.     'assign the juliand date string to the local storage variable
  107.     mvarJulian = Year & Right$(Month, 3)
  108.     
  109. End Sub
  110.  
  111.